package com.itwjs.mapper;

import com.itwjs.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * ClassName:UserMapper
 * Package:com.itwjs.mapper
 * Description:
 *
 * @Author 王久顺
 * @Create 2024/9/23 0:08
 * @Version 1.0
 */
@Mapper ////在运行时,会自动生成该接口的实现类对象(代理对象), 并且将该对象交给IOC容器管理
public interface UserMapper {
    //查询所有用户信息
    @Select("select * from user")
    public List<User> list();

    //根据主键id删除用户数据
    @Delete("delete from user where id = #{id}")
    public void delete(Integer id);

    //新增用户
    @Insert("insert into user(username, age) values(#{username},#{age})")
    public void insert(User user);

    //根据id修改用户信息
    @Update("update user set age = #{age},username = #{username} where id = #{id};")
    public void update(User user);
}
